<template>
    <div class="app">
        <app-header-nav
			v-if="!hideNav"
			v-model="active"
            @sliderClick="sliderClick"
            :navTab="navTab" />
        <div :class="[hideNav?'enterpricse_content':'']">
            <course v-if="active == 0"></course>
            <certificate v-if="active ==1"></certificate>
			 <dynamic ref="dynamic" v-if="active ==2"></dynamic>
             <brand v-if="active == 3"></brand>
             <recruil ref="recruil" v-if="active == 4"></recruil>
        </div>
        <edit-alert ref="editAlert"/>
    </div>
</template>

<script>
import AppHeaderNav from '@/components/App_header_nav'
import EditAlert from '@/pages/components/editAlert'
import Course from './components/course.vue'
import Certificate from './components/certificate'
import Brand from './components/brand'
import Recruil from './components/recruil'
import Dynamic from './components/dynamic'
export default {
	name: 'infoEdit',
	components: {
		AppHeaderNav,
		EditAlert,
		Course,
		Certificate,
		Brand,
		Recruil,
		Dynamic
	},
	data() {
		return {
			navTab: [
				{ text: '历程', id: 'course', des: '企业历程' },
				{ text: '证书', id: 'certificate', des: '获奖证书' },
				{ text: '动态', id: 'news', des: '企业动态' },
				{ text: '品牌', id: 'brand', des: '合作品牌' },
				{ text: '招聘', id: 'job', des: '企业招聘' }
			],
			active: 0,
			query: null,
			hideNav: false
		}
	},
	onShow(e) {
		if (this.active == 2) {
			this.$refs.dynamic.init()
		}
		if (this.active == 4) {
			this.$refs.recruil.init()
		}
	},
	onLoad(val) {
		this.query = val
		this.active = this.$util.isEmpty(val.active) ? 0 : val.active
		if (!this.$util.isEmpty(this.query.hideNav)) {
			this.hideNav = this.query.hideNav
		}
		uni.setNavigationBarTitle({
			title: this.navTab[this.active].des
		})
	},
	provide() {
		return {
			saveSuccee: this.saveSuccee,
			queryData: this.queryData
		}
	},
	methods: {
		saveSuccee() {
			this.$refs.editAlert.editalert = true
		},
		sliderClick(tab) {
			this.active = tab.idx
		},
		queryData() {
			return {
				...this.query
			}
		}
	}
}
</script>

<style lang="scss" scoped>
    .app {
        min-height: 100%;
        background-color: #f5f5f5;
        padding-bottom: 100px;
    }
	.enterpricse_content {
		padding-top: 25px;
	}
</style>
